{
 "cells": [
  {
   "cell_type": "raw",
   "id": "c2923bd1",
   "metadata": {},
   "source": [
    "---\n",
    "sidebar_label: AI21 Labs\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cc3c6ef6bbd57ce9",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# AI21Embeddings\n",
    "\n",
    "This notebook covers how to get started with AI21 embedding models.\n",
    "\n",
    "## Installation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4c3bef91",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install -qU langchain-ai21"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b4f3e15",
   "metadata": {},
   "source": [
    "## Environment Setup\n",
    "\n",
    "We'll need to get a [AI21 API key](https://docs.ai21.com/) and set the `AI21_API_KEY` environment variable:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "62e0dbc3",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import os\n",
    "from getpass import getpass\n",
    "\n",
    "os.environ[\"AI21_API_KEY\"] = getpass()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74ef9d8b40a1319e",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Usage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "12fcfb4b",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_ai21 import AI21Embeddings\n",
    "\n",
    "embeddings = AI21Embeddings()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1f2e6104",
   "metadata": {},
   "outputs": [],
   "source": [
    "embeddings.embed_query(\"My query to look up\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a3465d7e63bfb3d1",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "embeddings.embed_documents(\n",
    "    [\"This is a content of the document\", \"This is another document\"]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9d60af6d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
